﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using NUnit.Framework.Constraints;
using Simhopp.Model;


namespace NUnit.Framework.Tests
{
    [TestFixture]
    class TestCompetition
    {
        [Test]
        public void Constructor()
        {
            bool equal = false;
            DateTime DateCheck = new DateTime(2008,5,1);
            Competition comp = new Competition("VM-kval", CompetitionType.International,
                "Värnamo", new DateTime(2008,5,1), Height.Platform_10m, AgeClass.A, 'M',0,0);
            if (comp.Name == "VM-kval" &&
                comp.Event == CompetitionType.International &&
                comp.Location == "Värnamo" &&
                comp.Date == DateCheck &&
                comp.Height == Height.Platform_10m &&
                comp.AgeClass == AgeClass.A &&
                comp.Gender == 'M' &&
                comp.JudgingJudges == 0 &&
                comp.RoundsInCompetition == 0)
                equal = true;
            Assert.AreEqual(equal, true);

        }
        
        [Test]
        public void AddJudge()
        {
            //Check if judge is added
            Competition comp = new Competition(1,"VM-kval", CompetitionType.International,
                "Värnamo", new DateTime(2008, 5, 1), Height.Platform_10m, AgeClass.B, 'M', 0, 0);
            comp.AddJudge(new Judge(1, "Ser Dåligt", Countries.Sverige, "hemligt", "sd"));
            bool equal = false;
            Judge j = comp.GetJudge(1);
            if (j.Name == "Ser Dåligt" &&
                j.Nationality == Countries.Sverige &&
                j.Password == "hemligt" &&
                j.Username == "sd")
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void RemoveJudge()
        {
            //Check if judge is removed
            Competition comp = new Competition(1, "VM-kval", CompetitionType.International,
                "Värnamo", new DateTime(2008, 5, 1), Height.Platform_10m, AgeClass.B, 'M', 0, 0);
            comp.AddJudge(new Judge(1, "Ser Dåligt", Countries.Sverige, "hemligt", "sd"));
            bool equal = false;
            comp.RemoveJudge(1);
            Judge judge = comp.GetJudge(1);
            if (judge == null)
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void UpdateJudge()
        {
            //Check if judge is updated
            Competition comp = new Competition(1, "VM-kval", CompetitionType.International,
                "Värnamo", new DateTime(2008, 5, 1), Height.Platform_10m, AgeClass.B, 'M', 0, 0);
            comp.AddJudge(new Judge(1, "Ser Dåligt", Countries.Sverige, "hemligt", "sd"));
            bool equal = false;
            comp.UpdateJudge(1, "God Syn", Countries.Denmark, "felord", "gs");
            Judge judge = comp.GetJudge(1);
            if (judge.Name == "God Syn" &&
                judge.Nationality == Countries.Denmark &&
                judge.Password == "felord" &&
                judge.Username == "gs")
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void AddDiver()
        {
            //Check if Diver is added
            Competition comp = new Competition(1, "VM-kval", CompetitionType.International,
                "Värnamo", new DateTime(2008, 5, 1), Height.Platform_10m, AgeClass.B, 'M', 0, 0);
            comp.AddDiver(new Diver(1, "Fritt Fall", new DateTime(2005,5,5),'M',1, 23, Countries.Cuba));
            bool equal = false;
            Diver diver = comp.GetDiver(1);
            if (diver.Name == "Fritt Fall" &&
                diver.TotalPoints == 23 &&
                diver.Gender == 'M' &&
                diver.Nationality == Countries.Cuba)
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void RemoveDiver()
        {
            //Check if Diver is removed
            Competition comp = new Competition(1, "VM-kval", CompetitionType.International,
                "Värnamo", new DateTime(2008, 5, 1), Height.Platform_10m, AgeClass.B, 'M', 0, 0);
            Diver diver = new Diver(1, "Fritt Fall", new DateTime(2005, 5, 5), 'M', 1, 23, Countries.Cuba);
            comp.AddDiver(diver);
            bool equal = false;
            comp.RemoveDiver(diver);
            Diver diverCopy = comp.GetDiver(1);
            if (diverCopy == null)
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void UpdateDiver()
        {
            //Check if Diver is updated
            Competition comp = new Competition(1, "VM-kval", CompetitionType.International,
                "Värnamo", new DateTime(2008, 5, 1), Height.Platform_10m, AgeClass.B, 'M', 0, 0);
            Diver originalDiver = new Diver(1, "Fritt Fall", new DateTime(2005, 5, 5), 'M', 1, 23, Countries.Cuba);
            comp.AddDiver(originalDiver);
            bool equal = false;
            comp.UpdateDiver(originalDiver, new Diver(1, "Halka Av",new DateTime(2005,5,5),'F', 24,0, Countries.Ecuador));
            Diver diver = comp.GetDiver(1);
            if (diver.Name == "Halka Av" &&
                diver.Gender == 'F' &&
                diver.Nationality == Countries.Ecuador)
                equal = true;
            Assert.AreEqual(equal, true);
        }
        [Test]
        public void MoveDiverToBack()
        {
            bool equal = false;
            Competition comp = new Competition();
            Diver diver1 = new Diver(1, "Sören", new DateTime(1, 1, 1), 'M', 1, 0, Countries.Algeria);
            Diver diver2 = new Diver(2, "Sam", new DateTime(1, 1, 1), 'M', 2, 0, Countries.Andorra);
            Diver diver3 = new Diver(3, "Sven", new DateTime(1, 1, 1), 'M', 3, 0, Countries.Afghanistan);
            Diver diver4 = new Diver(4, "Simon", new DateTime(1, 1, 1), 'M', 4, 0, Countries.Angola);
            Diver diver5 = new Diver(5, "Salar", new DateTime(1, 1, 1), 'M', 5, 0, Countries.Laos);
            Diver diver6 = new Diver(6, "Sim Yun", new DateTime(1, 1, 1), 'F', 6, 0, Countries.Korea_South);
            comp.DiverList.Add(diver1);
            comp.DiverList.Add(diver2);
            comp.DiverList.Add(diver3);
            comp.DiverList.Add(diver4);
            comp.DiverList.Add(diver5);
            comp.DiverList.Add(diver6);
            Console.WriteLine("Before Change");
            foreach (Diver diver in comp.DiverList)
            {
                Console.WriteLine(diver.ID + ", " + diver.Name + ", " + diver.StartNumber);
            }
            comp.MoveDiverToBack(diver3);
            Console.WriteLine("After Change");
            foreach (Diver diver in comp.DiverList)
            {
                Console.WriteLine(diver.ID + ", " + diver.Name + ", " + diver.StartNumber);
            }
            if (comp.DiverList[5].ID == 3 &&
                comp.DiverList[5].Name == "Sven" &&
                comp.DiverList[5].StartNumber == 3)
                equal = true;
            Assert.AreEqual(equal, true);

        }
        [Test]
        public void AccessStartList()
        {
            //Return string, not empty
            Assert.AreEqual(false, true);
        }
        [Test]
        public void AccessResult()
        {
            //Return string, not empty
            Assert.AreEqual(false, true);
        }
        [Test]
        public void AddDiveResult()
        {
            //
            Assert.AreEqual(false, true);
        }
    }
}
